/*
 * @Author: 田鑫
 * @Date: 2023-02-21 16:34:47
 * @LastEditors: 田鑫
 * @LastEditTime: 2023-02-21 16:59:10
 * @Description:
 */

import router from '@/router';
import { clearToken } from '@/utils/auth';
import { Message } from '@arco-design/web-vue';

/**
 * 处理业务逻辑定义的错误code
 * @param errStatus
 */
export const handleCodeError = (error: any) => {
  let errMessage = '未知错误';
  console.log(error);
  errMessage = error.msg;
  switch (error.code) {
    case 1000:
      router.replace({
        name: '/login/password',
      });
      clearToken();
      break;
    default:
      errMessage = error.msg || `未知错误-${error.code}`;
  }
  Message.error(errMessage);
};
